#include "test.h"



namespace ns_BasicTypeTest
{
	const int COUNT = 10;

	void testSpan()
	{
		std::cout << "test span" << std::endl;

		Int32 arr[COUNT];
		for (int i = 0; i < COUNT; i++)
		{
			arr[i] = i;
		}

		Span<Int32> span(arr, COUNT);
		for (int i = 0; i < span.Length; i++)
		{
			std::cout << span.DataPtr[i] << std::endl;
		}

		std::cout << "\r\nspan.first():" << span.First() << "	span.last():" << span.Last() << std::endl;

		std::cout << "\r\ntest span.Slice(5,5)" << std::endl;
		Span<Int32> span2 = span.Slice(5, 5);
		for (int i = 0; i < span2.Length; i++)
		{
			std::cout << span2.DataPtr[i] << std::endl;
		}

		std::cout << "\r\ntest span2.fill(20)" << std::endl;
		span2.Fill(20);
		for (int i = 0; i < span2.Length; i++)
		{
			std::cout << span2.DataPtr[i] << std::endl;
		}

		std::cout << "\r\ntest span2.Clear()" << std::endl;
		span2.Clear();
		for (int i = 0; i < span2.Length; i++)
		{
			std::cout << span2.DataPtr[i] << std::endl;
		}
	}

	void testIQSpan()
	{
		std::cout << "\r\ntest iqspan" << std::endl;
		Int32 iData[COUNT];
		Int32 qData[COUNT];
		for (int i = 0; i < COUNT; i++)
		{
			iData[i] = 10 + i;
			qData[i] = 100 + i;
		}

		IQSpan<Int32> iqSpan(iData, qData, COUNT);
		for (int i = 0; i < iqSpan.Length; i++)
		{
			std::cout << "I:" << iqSpan.IDataPtr[i] << "  q:" << iqSpan.QDataPtr[i] << std::endl;
		}

		std::cout << "\r\ntest iqSpan.Slice(5,5)" << std::endl;
		IQSpan<Int32> iqSpan2 = iqSpan.Slice(5, 5);
		for (int i = 0; i < iqSpan2.Length; i++)
		{
			std::cout << "I:" << iqSpan2.IDataPtr[i] << "  q:" << iqSpan2.QDataPtr[i] << std::endl;
		}

		std::cout << "\r\ntest iqSpan2.fill(20)" << std::endl;
		iqSpan2.Fill(20);
		for (int i = 0; i < iqSpan2.Length; i++)
		{
			std::cout << "I:" << iqSpan2.IDataPtr[i] << "  q:" << iqSpan2.QDataPtr[i] << std::endl;
		}

		std::cout << "\r\ntest iqSpan2.Clear()" << std::endl;
		iqSpan2.Clear();
		for (int i = 0; i < iqSpan2.Length; i++)
		{
			std::cout << "I:" << iqSpan2.IDataPtr[i] << "  q:" << iqSpan2.QDataPtr[i] << std::endl;
		}
	}
}


void BasicTypeTest::test()
{
	ns_BasicTypeTest::testSpan();
	ns_BasicTypeTest::testIQSpan();

}


